import requests
from bs4 import BeautifulSoup
import pandas as pd
import re
import warnings
import sys

type = sys.getfilesystemencoding()
warnings.filterwarnings("ignore", category=DeprecationWarning)

'''
获取网页关联的子链接名称+子链接
'''
def crawl_ityouknow():
    url = "http://www.ityouknow.com/spring-boot.html"
    response = requests.get(url)
    # 检查响应状态码
    # if response.status_code == 200:
    #     # 打印响应内容
    #     print(response.content.decode('utf-8'))
    # else:
    #     print('请求失败:', response.status_code)

    soup = BeautifulSoup(response.content.decode('utf-8'), 'html.parser')

    articles = soup.find_all('a', class_='posts-list-name bubble-float-left')

    for article in articles:
        article_name = article.text.strip()
        article_link = article['href']
        # 打印文章名称和链接
        print(article_name+":"+article_link)

if __name__ == "__main__":
    crawl_ityouknow()
